<?php
namespace Users\Model;

use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql;
use Zend\Db\Sql\Where;
use Zend\Db\Sql\Select;
use Zend\Paginator\Adapter\DbSelect;
use Zend\Paginator\Paginator;
use Zend\Db\Sql\Predicate;
use Zend\Db\Sql\Expression;

class OrdersInfoTable
{
    protected $tableGateway;
	protected $select;
    public function __construct(TableGateway $tableGateway)
    {
        $this->tableGateway = $tableGateway;
		$this->select = new Select();
    }	
	public function addOrderinfo($main_Id,$printpaper,$magazine,$homedelivery)
    {
		if($printpaper!=''){
			$paper_ads_type=$printpaper['paper_print'];
			$paper_ads_amount=$printpaper['paper_sur_charge'];
			$paper_circ_id=$printpaper['paper_populationpaperdrop'];
			$paper_circ_amount=$printpaper['paper_amount'];
			$paper_ad_title=$printpaper['paper_title_paper'];
			$paper_ad_image='';
			$paper_image_dimension_wh='';
			//$paper_image_dimension_wh=$printpaper['paper_avi_dimensions'];
			$paper_image_amount='';
			//$paper_image_amount=$printpaper['paper_price_dimension_paper'];
			$paper_ads_text=$printpaper['paper_textAreaPaper'];
			$paper_letters_length=$printpaper['paper_length_paper'];
			$paper_ads_text_amount=$printpaper['paper_letter_price'];
			$paper_starting_date=$printpaper['paper_start_date'];
			$paper_ending_date=$printpaper['paper_end_date'];
			$paper_selecting_dates='';
			$paper_week_days_order=$printpaper['paper_weekdays_st'];
			$paper_week_ends_order=$printpaper['paper_weekends_st'];
			$paper_dates_amount_order=$printpaper['paper_week_st_amount'];
			$paper_text_color=$printpaper['paper_text_color_db'];
		}else{
			$paper_ads_type='';
			$paper_ads_amount='';
			$paper_circ_id='';
			$paper_circ_amount='';
			$paper_ad_title='';
			$paper_ad_image='';
			$paper_image_dimension_wh='';
			$paper_image_amount='';
			$paper_ads_text='';
			$paper_letters_length='';
			$paper_ads_text_amount='';
			$paper_starting_date='';
			$paper_ending_date='';
			$paper_selecting_dates='';
			$paper_week_days_order='';
			$paper_week_ends_order='';
			$paper_dates_amount_order='';
			$paper_text_color='';
		}
		if($magazine!=''){
			$magazine_ads_type_name=$magazine['magazine_magazineCheck'];
			$magazine_ads_type_amount=$magazine['magazine_sur_charge_magazine'];   
			$magazine_ads_order_period=$magazine['magazine_periodtime'];  
			$magazine_ad_title=$magazine['magazine_titleMagazine'];          
			$magazine_ad_image=''; 	     
			//$magazine_ad_image=$magazine['magazine_magazineCheck']; 	     
			$magazine_image_dimension_wh='';
			//$magazine_image_dimension_wh=$magazine['magazine_avi_dimensions'];
			$magazine_image_amount='';  	 
			//$magazine_image_amount=$magazine['magazine_price_dimension_magiz'];  	 
			$magazine_ads_text=$magazine['magazine_textAreaMagazine']; 	 
			$magazine_letters_length=$magazine['magazine_length_magazine']; 	 
			$magazine_ads_text_amount=$magazine['magazine_letter_price']; 	 
			$magazine_period_order_amount=$magazine['magazine_period_amount'];
			$magazine_period_date=$magazine['magazine_start_date'];
			$magazine_text_color=$magazine['magazine_text_color_db'];
		}else{
			$magazine_ads_type_name='';
			$magazine_ads_type_amount='';   
			$magazine_ads_order_period='';  
			$magazine_ad_title='';          
			$magazine_ad_image=''; 	     
			$magazine_image_dimension_wh='';
			$magazine_image_amount='';  	 
			$magazine_ads_text=''; 	 
			$magazine_letters_length=''; 	 
			$magazine_ads_text_amount=''; 	 
			$magazine_period_order_amount='';
			$magazine_period_date='';
			$magazine_text_color='';
		}
		if($homedelivery!=''){
			$home_ads_type_name=$homedelivery['home_homedelevarycheck'];	 
			$home_ads_type_amount=$homedelivery['home_sur_charge_home'];   
			$home_ad_title=$homedelivery['home_titleHome'];          
			//$home_ad_image=$homedelivery['home_homedelevarycheck']; 	     
			$home_ad_image=''; 	     
			$home_image_dimension_wh='';
			//$home_image_dimension_wh=$homedelivery['home_avi_dimensions'];
			$home_image_amount='';  	 
			$home_image_amount='';  	 
			//$home_image_amount=$homedelivery['home_price_dimension_home'];  	 
			$home_ads_text=$homedelivery['home_textAreaHome']; 	 
			$home_letters_length=$homedelivery['home_length_home_delivery']; 	 
			$home_ads_text_amount=$homedelivery['home_letter_price']; 	 
			$home_ads_radius=$homedelivery['home_radius'];        
			$home_ads_radius_amount=$homedelivery['home_radius_amount']; 
			$home_delivery_date=$homedelivery['home_start_date']; 
			$home_text_color=$homedelivery['home_text_color_db'];
		}else{
			$home_ads_type_name='';	 
			$home_ads_type_amount='';   
			$home_ad_title='';          
			$home_ad_image=''; 	     
			$home_image_dimension_wh='';
			$home_image_amount='';  	 
			$home_ads_text=''; 	 
			$home_letters_length=''; 	 
			$home_ads_text_amount=''; 	 
			$home_ads_radius='';        
			$home_ads_radius_amount=''; 
			$home_delivery_date='';
			$home_text_color='';
		}
		$data = array(
			'ads_posted_id' 	            =>$main_Id, 			
			'paper_ads_type_name' 	        =>$paper_ads_type,
			'paper_ads_type_amount'         =>$paper_ads_amount,			
			'paper_cir_id' 	                =>$paper_circ_id, 	
			'paper_amount' 	                =>$paper_circ_amount, 	
			'paper_ad_title'                =>$paper_ad_title,  	
			'paper_ad_image' 	            =>$paper_ad_image,   
			'paper_image_dimension_wh'      =>$paper_image_dimension_wh, 	
			'paper_image_amount'  	        =>$paper_image_amount,
			'paper_ads_text' 	            =>$paper_ads_text,
			'paper_letters_length' 	        =>$paper_letters_length,
			'paper_ads_text_amount' 	    =>$paper_ads_text_amount,
			'paper_starting_date' 	        =>$paper_starting_date,
			'paper_ending_date' 	        =>$paper_ending_date, 
			'paper_selecting_dates' 	    =>$paper_selecting_dates, 
			'paper_week_days_order' 	    =>$paper_week_days_order, 
			'paper_week_ends_order' 	    =>$paper_week_ends_order, 
			'paper_dates_amount_order'      =>$paper_dates_amount_order, 
			'paper_text_color'              =>$paper_text_color, 
			
			'magazine_ads_type_name' 	    =>$magazine_ads_type_name,
			'magazine_ads_type_amount'      =>$magazine_ads_type_amount,		
			'magazine_ads_order_period'     =>$magazine_ads_order_period,
			'magazine_ad_title'             =>$magazine_ad_title,  	
			'magazine_ad_image' 	        =>$magazine_ad_image,   
			'magazine_image_dimension_wh'   =>$magazine_image_dimension_wh, 	
			'magazine_image_amount'  	    =>$magazine_image_amount,
			'magazine_ads_text' 	        =>$magazine_ads_text,
			'magazine_letters_length' 	    =>$magazine_letters_length,
			'magazine_ads_text_amount' 	    =>$magazine_ads_text_amount,
			'magazine_period_order_amount'  =>$magazine_period_order_amount, 
			'magazine_period_date'          =>$magazine_period_date,
		    'magazine_text_color'          =>$magazine_text_color,
			
			'home_ads_type_name' 	     =>$home_ads_type_name,
			'home_ads_type_amount'       =>$home_ads_type_amount,		
			'home_ad_title'              =>$home_ad_title,  	
			'home_ad_image' 	         =>$home_ad_image,   
			'home_image_dimension_wh'    =>$home_image_dimension_wh, 	
			'home_image_amount'  	     =>$home_image_amount,
			'home_ads_text' 	         =>$home_ads_text,
			'home_letters_length' 	     =>$home_letters_length,
			'home_ads_text_amount' 	     =>$home_ads_text_amount,
			'home_ads_radius'            =>$home_ads_radius, 
			'home_ads_radius_amount'     =>$home_ads_radius_amount, 
			'home_delivery_date'         =>$home_delivery_date, 
			'home_text_color'           =>$home_text_color, 
			
			'added_date' 	    => date('Y-m-d H:i:s'),
			'updated_date' 	    => date('Y-m-d H:i:s'), 
		);
		$this->tableGateway->insert($data);
		return $this->tableGateway->lastInsertValue;	
    }
}